//
//  HomeNavigationController.m
//  News
//
//  Created by lanou3g on 15/11/4.
//  Copyright © 2015年 songhaowen. All rights reserved.
//

#import "HomeNavigationController.h"
#import "NSString+Extension.h"


@interface HomeNavigationController ()

@end

@implementation HomeNavigationController

- (void)viewDidLoad {
    [super viewDidLoad];

    [self setUpNavBar];//导航栏
    

}

//导航栏
-(void)setUpNavBar
{
    
    
 //////缓存按钮
    UIButton *titleBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 24, SW , 40)];
 
     // 缓存路径
    NSString *caches = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject];

    [titleBtn setTitle:[NSString stringWithFormat:@"清除(缓存:%ldM)",(long)[caches fileSize]/1000/1000] forState:UIControlStateNormal];//
    titleBtn.backgroundColor =[UIColor lightGrayColor];//
    titleBtn.showsTouchWhenHighlighted = NO;
    [titleBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    titleBtn.titleLabel.font = [UIFont systemFontOfSize:18];
    titleBtn.titleLabel.numberOfLines = 0;
    [titleBtn addTarget:self action:@selector(qingchuhuancun) forControlEvents:UIControlEventTouchUpInside];//
    [self.view addSubview:titleBtn];
    
    
    
/////刷新按钮
//    UIButton *refreshBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 24, 100, 40)];
//    [refreshBtn setTitle:@"刷新" forState:UIControlStateNormal];//
//    refreshBtn.backgroundColor =[UIColor lightGrayColor];//
//    refreshBtn.showsTouchWhenHighlighted = YES;//点击的时候有亮点
//    refreshBtn.titleLabel.font = [UIFont systemFontOfSize:18];
//     refreshBtn.titleLabel.numberOfLines = 0;
//    [self.view addSubview:refreshBtn];
//     //点击刷新
//    [refreshBtn addTarget:self action:@selector(refresh)  forControlEvents:UIControlEventTouchUpInside];
    
}



//点击清除缓存
-(void)qingchuhuancun{
    // 文件管理者
    NSFileManager *mgr = [NSFileManager defaultManager];
    // 缓存路径
    NSString *caches = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject];
    [mgr removeItemAtPath:caches error:nil];
    NSLog(@"清除缓存----NSCachesDirectory文件夹被删除!");
    [self setUpNavBar];
}

  //点击刷新
//-(void)refresh{
//    [[NSNotificationCenter defaultCenter] postNotificationName:@"ShuaXinA" object:nil];//通知
//}









@end
